/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.kj.entity;

import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import com.jeesite.common.utils.excel.fieldtype.CompanyType;
import com.jeesite.common.utils.excel.fieldtype.OfficeType;
import org.hibernate.validator.constraints.Length;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

import javax.validation.Valid;
import java.math.BigDecimal;

import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
/**
 * kj_member_jobEntity
 * @author hzy
 * @version 2021-07-12
 */
@Table(name="kj_member_job", alias="a", columns={
		@Column(name="id", attrName="id", label="id", isPK=true),
		@Column(name="activity_id", attrName="activityId", label="活动ID"),
		@Column(name="job_id", attrName="jobId", label="岗位ID"),
		@Column(name="member_id", attrName="kjMember.id", label="用户ID"),
		@Column(includeEntity=DataEntity.class),
		@Column(name="member_name", attrName="kjMember.name", label="用户名", queryType=QueryType.LIKE),
		@Column(name="approve_status", attrName="approveStatus", label="审批状态"),
		@Column(name="activity_name", attrName="activityName", label="活动名", queryType=QueryType.LIKE),
		@Column(name="job_name", attrName="jobName", label="岗位名", queryType=QueryType.LIKE),
		@Column(name="apply", attrName="apply", label="申请理由", queryType=QueryType.LIKE),
		@Column(name="send_status", attrName="sendStatus", label="积分发放状态"),
		@Column(name="integrals", attrName="integrals", label="可获得积分"),
		@Column(name="service_time", attrName="serviceTime", label="可获得服务时长"),
		@Column(name="city_id", attrName="cityId", label="所在城市id"),
		@Column(name="city_name", attrName="cityName", label="所在城市"),
	}, joinTable={
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= KjMember.class, alias="m",
				on="m.id = a.member_id",
				columns={@Column(includeEntity=KjMember.class)}),

		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= KjActivity.class, alias="ka",
				on="ka.id = a.activity_id",
				columns={@Column(includeEntity=KjActivity.class)}),

		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= KjActivityJob.class, alias="kaj",
				on="kaj.id = a.job_id",
				columns={@Column(includeEntity=KjActivityJob.class)})
}, orderBy="a.create_date DESC"
)
public class KjMemberJob extends DataEntity<KjMemberJob> {

	private static final long serialVersionUID = 1L;
	public static final String PROCESSING = "0";
	public static final String OK = "1";
	public static final String REJECT = "2";
	public static final String FINISH = "3";

	public static final String UNSEND = "0";
	public static final String SENDED = "1";
	public static final String SENDRELECT = "2";
	private String activityId;		// 活动ID
	private String jobId;		// 岗位ID
	private KjMember kjMember;
	private String approveStatus;		// 审批状态
	private String activityName;		// 活动名
	private String jobName;		// 岗位名
	private String apply;		// 岗位名
	private String sendStatus;
	private BigDecimal integrals;
	private BigDecimal serviceTime;
	private String cityId;
	private String cityName;
	private String createDateStr;
	private KjActivity kjActivity;
	private KjActivityJob kjActivityJob;


	private BigDecimal calculateTime;

	public KjMemberJob() {
		this(null);
	}

	public KjMemberJob(String id){
		super(id);
	}


	@Valid
	@ExcelFields({
			@ExcelField(title="活动名", attrName="activityName", align=Align.CENTER, sort=10, fieldType= OfficeType.class),
			@ExcelField(title="地区", attrName="cityName", align = Align.CENTER, sort=20, fieldType= CompanyType.class),
			@ExcelField(title="用户名", attrName="kjMember.name", align=Align.CENTER, sort=30),
			@ExcelField(title="中兴工号", attrName="kjMember.memberNo", align=Align.CENTER, sort=32),
			@ExcelField(title="电话", attrName="kjMember.mobile", align=Align.CENTER, sort=34),
			@ExcelField(title="岗位名", attrName="kjActivityJob.jobName", align=Align.CENTER, sort=40),
			@ExcelField(title="申请原因", attrName="apply", align=Align.LEFT, sort=50),
			@ExcelField(title="审批状态", attrName="approveStatus", dictType = "approve_status", align=Align.CENTER, sort=60),
			@ExcelField(title="备注", attrName="remarks", align=Align.CENTER, sort=60),
	})

	@Length(min=0, max=64, message="活动ID长度不能超过 64 个字符")
	public String getActivityId() {
		return activityId;
	}

	public void setActivityId(String activityId) {
		this.activityId = activityId;
	}

	@Length(min=0, max=64, message="岗位ID长度不能超过 64 个字符")
	public String getJobId() {
		return jobId;
	}

	public void setJobId(String jobId) {
		this.jobId = jobId;
	}

	@Length(min=0, max=1, message="审批状态长度不能超过 1 个字符")
	public String getApproveStatus() {
		return approveStatus;
	}

	public void setApproveStatus(String approveStatus) {
		this.approveStatus = approveStatus;
	}

	@Length(min=0, max=255, message="活动名长度不能超过 255 个字符")
	public String getActivityName() {
		return activityName;
	}

	public void setActivityName(String activityName) {
		this.activityName = activityName;
	}

	@Length(min=0, max=255, message="岗位名长度不能超过 255 个字符")
	public String getJobName() {
		return jobName;
	}

	public void setJobName(String jobName) {
		this.jobName = jobName;
	}

	public String getApply() {
		return apply;
	}

	public void setApply(String apply) {
		this.apply = apply;
	}

	public KjMember getKjMember() {
		return kjMember;
	}

	public void setKjMember(KjMember kjMember) {
		this.kjMember = kjMember;
	}

	public String getSendStatus() {
		return sendStatus;
	}

	public void setSendStatus(String sendStatus) {
		this.sendStatus = sendStatus;
	}

	public BigDecimal getIntegrals() {
		return integrals;
	}

	public void setIntegrals(BigDecimal integrals) {
		this.integrals = integrals;
	}


	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getCreateDateStr() {
		return createDateStr;
	}

	public void setCreateDateStr(String createDateStr) {
		this.createDateStr = createDateStr;
	}

	public void setApproveStatusNotIn(String[] approveStatuses){
		getSqlMap().getWhere().and("approve_status", QueryType.NOT_IN, approveStatuses);
	}

	public BigDecimal getServiceTime() {
		return serviceTime;
	}

	public void setServiceTime(BigDecimal serviceTime) {
		this.serviceTime = serviceTime;
	}

	public KjActivity getKjActivity() {
		if(kjActivity == null){
			this.kjActivity = new KjActivity();
		}
		return kjActivity;
	}

	public void setKjActivity(KjActivity kjActivity) {
		this.kjActivity = kjActivity;
	}

	public KjActivityJob getKjActivityJob() {
		return kjActivityJob;
	}

	public void setKjActivityJob(KjActivityJob kjActivityJob) {
		this.kjActivityJob = kjActivityJob;
	}

	public BigDecimal getCalculateTime() {
		if("1".equals(getSendStatus())){
			return serviceTime;
		}
		return BigDecimal.ZERO;
	}

	public void setCalculateTime(BigDecimal calculateTime) {
		this.calculateTime = calculateTime;
	}
}
